package com.example.shop_2304.adapter

import android.widget.ImageView
import android.widget.LinearLayout
import androidx.core.view.isVisible
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.shop_2304.R
import com.example.shop_2304.room.Comment
import com.example.shop_2304.utils.GlideUtils

class CommentAdapter:BaseQuickAdapter<Comment,BaseViewHolder>(R.layout.item_comment) {
    override fun convert(holder: BaseViewHolder, item: Comment) {
        holder.setText(R.id.com_phone,item.phone)
        holder.setText(R.id.com_time,item.time)
        holder.setText(R.id.com_msg,item.msg)
        if(item.pic_one==""){//3个图片都没有上传  所有图片 均不显示
            holder.getView<LinearLayout>(R.id.ll_com_img).isVisible = false

        }else if(item.pic_two==""){ //只有1上传了 其他两个图片不显示
            GlideUtils.loadImage(context,item.pic_one!!,holder.getView(R.id.com_img1))
            holder.getView<ImageView>(R.id.com_img2).isVisible = false
            holder.getView<ImageView>(R.id.com_img3).isVisible = false

        }else if(item.pic_three==""){//只有1,2上传了 第三张图片不显示
            GlideUtils.loadImage(context,item.pic_one!!,holder.getView(R.id.com_img1))
            GlideUtils.loadImage(context,item.pic_two!!,holder.getView(R.id.com_img2))
            holder.getView<ImageView>(R.id.com_img3).isVisible = false
        }else{
            GlideUtils.loadImage(context,item.pic_one!!,holder.getView(R.id.com_img1))
            GlideUtils.loadImage(context,item.pic_two!!,holder.getView(R.id.com_img2))
            GlideUtils.loadImage(context,item.pic_three!!,holder.getView(R.id.com_img3))
        }

    }
}